package com.myapplication.ui.listfragment;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.myapplication.R;
import com.myapplication.bean.ListBean;

import java.util.List;

/**
 * Created by My on 2016/10/14.
 */
public class ListRecycleViewAdapter extends RecyclerView.Adapter<ListRecycleViewAdapter.MyViewHolder> {
    private Context context;
    private List<ListBean.DataBean.ItemsBean> list;

    public ListRecycleViewAdapter(Context context,List<ListBean.DataBean.ItemsBean>  list){
        this.context=context;
        this.list=list;
    }

    @Override
    public MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        MyViewHolder holder=new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.item_rv_list,null));
        return holder;
    }

    @Override
    public void onBindViewHolder(MyViewHolder holder, int position) {
        String imageurl=list.get(position).getImageUrl();
        Glide.with(context).load(imageurl).into(holder.iv);
    }

    @Override
    public int getItemCount() {
        Log.i("getItemCount", "getItemCount: "+list.toString());
        return list.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
         ImageView iv;
         public MyViewHolder(View itemView) {
             super(itemView);
             iv= (ImageView) itemView.findViewById(R.id.iv_small_list);
         }
     }


//    public static interface OnRecyclerViewListener{
//        void onItemClick(int posion);
//        boolean onItemLongClick(int position);
//    }
//    private OnRecyclerViewListener onRecyclerViewListener;
//
//    public void setOnRecyclerViewListener(OnRecyclerViewListener onRecyclerViewListener) {
//                this.onRecyclerViewListener = onRecyclerViewListener;
//            }


}
